<?php

namespace App\Http\Middleware\Api;

use Closure;

class FormatResponseData
{
    public function handle($request, Closure $next)
    {
        $response = $next($request);

        if(!array_key_exists('code', $response->getData(true))){
            $response->setData(['code' => 2000, 'message' => '', 'data' => $response->getData(true)]);
        }

        return $response;
    }
}
